<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    
</body>
<script>
    // 原始代码
    function getAdultUsers(users) {
        const result = [];
        for (let i = 0; i < users.length; i++) {
            if (users[i].age >= 18) {
                result.push(users[i]);
            }
        }
        return result;
    }

    // 优化后
    function getAdultUsers(users) {
        return users.filter(user => user.age >= 18);
    }
</script>
</html>